<template>
    <div class="agreement" @click="chooseAgreement">
        <div class="checkbox">
            <img src="@/assets/images/my/gou.png" class="img" alt="" v-if="!checked">
            <img src="@/assets/images/my/gou_active.png" class="img" alt="" v-else>
        </div>
        <div class="">
            <slot />
        </div>
    </div>
</template>
<script>
export default {
    name: 'Agreement',
    props: {
        value: {
            type: Boolean,
            default: true,
        }
    },
    watch: {
        value: {
            handler: function (n) {
                this.checked = n;
            },
            immediate: true
        }
    },
    data() {
        return {
            checked: true
        }
    },
    methods: {
        // 勾选用户协议
        chooseAgreement() {
            this.checked = !this.checked;
            this.$emit('input', this.checked)
        }
    }
}
</script>
<style lang="less" scoped>
@import './index.less';
</style>